<?xml version="1.0"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Define common Csla Factory Methods</Title>
      <Author>Rockford Lhotka</Author>
      <Description>Defines common Csla-style factory methods.</Description>
      <Shortcut>cslafact</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>ClassName</ID>
          <Type>String</Type>
          <ToolTip>Replace with class name.</ToolTip>
          <Default>BusinessClass</Default>
        </Literal>
        <Literal>
          <ID>IdName</ID>
          <Type>String</Type>
          <ToolTip>Replace with Id (primary key) variable name.</ToolTip>
          <Default>id</Default>
        </Literal>
        <Literal>
          <ID>IdType</ID>
          <ToolTip>Replace with the Id (primary key) variable type.</ToolTip>
          <Default>int</Default>
        </Literal>
      </Declarations>
      <Code Language="CSharp">
  <![CDATA[public static void New$ClassName$(EventHandler<DataPortalResult<$ClassName$>> callback)
{
  DataPortal.BeginCreate<$ClassName$>(callback);
}

public static void Get$ClassName$($IdType$ $IdName$, EventHandler<DataPortalResult<$ClassName$>> callback)
{
  DataPortal.BeginFetch<$ClassName$>($IdName$, callback);
}

public static async Task<$ClassName$> New$ClassName$Async()
{
  return await DataPortal.CreateAsync<$ClassName$>();
}

public static async Task<$ClassName$> Get$ClassName$Async($IdType$ $IdName$)
{
  return await DataPortal.FetchAsync<$ClassName$>($IdName$);
}

#if !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE

public static $ClassName$ New$ClassName$()
{
  return DataPortal.Create<$ClassName$>();
}

public static $ClassName$ Get$ClassName$($IdType$ $IdName$)
{
  return DataPortal.Fetch<$ClassName$>($IdName$);
}

public static void Delete$ClassName$($IdType$ $IdName$)
{
  DataPortal.Delete<$ClassName$>($IdName$);
}

#endif]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>